{{extend 'layout.html'}}
{{ import applications.init.modules.markdown as markdown }}

{{ for post in posts: }}
<div class="maincontent">
	<h1 class="sectionheading">
		<a href="/{{=request.application}}/posts/view/{{= post.id }}">{{= post.title }}</a>
	</h1>
	<p class="post-social">
        <!-- Place this tag where you want the +1 button to render. -->
        <div class="g-plusone" data-annotation="none" href="{{=request.env.wsgi_url_scheme}}://{{=request.env.http_host}}/{{=request.application}}/posts/view/{{= post.id }}"></div>
        <!-- Place this tag after the last +1 button tag. -->
        <script type="text/javascript">
          (function() {
            var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
            po.src = 'https://apis.google.com/js/plusone.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
          })();
        </script>
		<a class="post-twitter"  title="Twitter" target="_blank" href="http://twitter.com/intent/tweet?url=http://pleph.appspot.com/{{=request.application}}/posts/view/{{= post.id }}&text=New Pleph Post: {{= post.title }}"></a>
		<div class="fb-like" style="align: right" data-href="http://pleph.appspot.com/{{=request.application}}/posts/view/{{= post.id }}" data-send="true" data-layout="button_count" data-width="450" data-show-faces="true"></div>
	</p>
	<pre class="subinfo" style="font-size: 8pt; text-align: left;">Posted by <strong>{{=post.username}}</strong> on <strong>{{=str(post.addeddate)[:10]}}</strong></pre>
	{{ if post.excerpt: }}
	<div>{{= markdown.WIKI(post.excerpt, safe_mode = "safe") }}</div>
	<div align="right">
		<a href="/{{=request.application}}/posts/view/{{= post.id }}">read more...</a>
	</div>
	{{ else: }}
	<div>{{= markdown.WIKI(post.body, safe_mode = "safe") }}</div>
	{{ pass }}
    <div class="subinfo" id="container">
        <div id="row">
            {{ if categories: }}
                <div id="left">
                {{ categorycounter = 1 }}
                <div><strong>Categories</strong>
                    {{ for category in categories[post.id]: }}
                    <a href="/{{=request.application}}/categories/view/{{= category }}">{{= categories[post.id][category] }}</a>{{ if categorycounter != len(categories[post.id]): }}, {{ else: }}. {{ pass }}
                    {{ categorycounter = categorycounter + 1 }}
                    {{ pass }}
                    </div>
                </div>
            {{ pass }}
            {{ if tags: }}
                <div id="middle">
                <div><strong>Tags: </strong>
                    {{= ", ".join(tags[post.id]) }}
                </div>
                </div>
            {{ pass }}
            <div id="right-comments">
                <strong>Comments:</strong> <a href="/{{=request.application}}/posts/view/{{= post.id }}#Comments">{{=comments[post.id]}}</a>
            </div>
        </div>
    </div>
</div>
<br/>
{{ pass }}
